from django.db import models


class BuyerUser(models.Model):
    telephone = models.CharField(max_length=11)
    password = models.CharField(max_length=32)

    username = models.CharField(max_length=32)
    phone_number = models.CharField(max_length=11, null=True, blank=True)
    photo = models.ImageField(upload_to='images', null=True, blank=True)
    age = models.CharField(max_length=32, null=True, blank=True)
    gender = models.CharField(max_length=32, null=True, blank=True)
    address = models.TextField(max_length=254, null=True, blank=True)


class GoodsType(models.Model):
    type_label = models.CharField(max_length=32)
    type_description = models.TextField()
    type_picture = models.ImageField()


class Goods(models.Model):
    goods_picture = models.ImageField()                           # 图  片
    goods_title = models.CharField(max_length=255)                # 名  称
    goods_RP = models.CharField(max_length=8)                     # 原  价
    goods_current_price = models.CharField(max_length=8)          # 活动价
    goods_count = models.CharField(max_length=32)                 # 数  量
    goods_safe_date = models.CharField(max_length=32)             # 保质期
    goods_pro_time = models.DateField(auto_now=True)              # 生产期
    goods_location = models.CharField(max_length=254)             # 生产地
    goods_status = models.CharField(max_length=32)                # 状  态
    goods_people_buy = models.CharField(max_length=32)            # 购买数
    goods_type = models.ForeignKey(to=GoodsType, on_delete=models.CASCADE, default=1)   # 商品类型
    goods_store = models.ForeignKey(to=BuyerUser, on_delete=models.CASCADE, default=1)  # 商品店铺
    goods_detai_href = models.CharField(max_length=252)





# Create your models here.
